//
//  HMTabBarController.swift
//  Weibo
//
//  Created by 吴少飞 on 16/9/19.
//  Copyright © 2016年 wushaofei. All rights reserved.
//

import UIKit

class HMTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        UITabBar.appearance().tintColor = UIColor.orange
        
        let btn = HMTabBar()
        
        setValue(btn, forKey: "tabBar")
        
        setupUI()
    }

    func setupUI(){
        

        addChildViewController(childController: HMHomeController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(childController: HMMessageController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(childController: HMDiscoverController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(childController: HMProfileController(), title: "我的", imageName: "tabbar_profile")
        
        
    }

    
    //添加自控制器重载方法
    func addChildViewController(childController: UIViewController,title:String,imageName:String) {
        
        
        childController.title = title
        
        //设置图片普通样式和选中样式
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        
        //设置选中颜色
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orange], for: .selected)
        
        //设置字体大小
        childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName:UIFont.systemFont(ofSize: 14)], for: .normal)
        
        let vc = HMNavigationController(rootViewController: childController)
        
        addChildViewController(vc)
        
    }
    
    



}
